package com.wlz.consumer.consumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.rpc.service.GenericService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;

import java.io.IOException;

/**
 * @author wlz
 * @date 2022-07-13  12:23 上午
 */
@Slf4j
@EnableAutoConfiguration
public class GenericDubboConsumerDemo {

    @Reference(id = "demoService", version = "default", interfaceName = "com.wlz.api.DemoService", generic = true)
    private GenericService genericService;

    public static void main(String[] args) throws IOException {
        ConfigurableApplicationContext context = SpringApplication.run(GenericDubboConsumerDemo.class);

        GenericService genericService = (GenericService) context.getBean("demoService");

        Object result = genericService.$invoke("sayHello", new String[]{"java.lang.String"}, new Object[]{"wlz"});
        log.info("result : {}", result);


    }
}
